using MediatR;
using SumerCoreDevOps.Application.NodeLogs.Queries;
using SumerCoreDevOps.Infrastructure.Logging;

namespace SumerCoreDevOps.Application.NodeLogs.Handlers;

public class GetLogStatisticsQueryHandler : IRequestHandler<GetLogStatisticsQuery, NodeOperationLogStatistics>
{
    private readonly NodeOperationLogManager _logManager;

    public GetLogStatisticsQueryHandler(NodeOperationLogManager logManager)
    {
        _logManager = logManager;
    }

    public async Task<NodeOperationLogStatistics> Handle(GetLogStatisticsQuery request, CancellationToken cancellationToken)
    {
        return await _logManager.GetStatisticsAsync(request.StartDate, request.EndDate, request.NodeId);
    }
}
